﻿using System;
using Sharp.Domain.PlatformBoundedContext.StoragerModule.Files;
using Sharp.Domain.PlatformBoundedContext.UserModule.Aggregates;
using Sharp.Events;
using Sharp.Infrastructure.IoC;

namespace Sharp.Domain.PlatformBoundedContext.StoragerModule.Events
{
    [Async(false)]
    public class StorageEventHandler : IEventHandler<StorageChangedEventData>
    {
        public StorageEventHandler()
        {
        }
        public void Handle(StorageChangedEventData e)
        {
            if (e.File.IsNullOrEmpty())
            {
                return;
            }
            var id = SharpStorager.Context.AddOrUpdate(e.File);

            //var model = (User)e.EventSource;
            //model.Face = id;

            e.HandlerData?.Invoke(id);
        }
    }
}